
const rows = []



transData(rows) {
    // 中英文映射关系
const map = {
    'id': '编号',
    'password': '密码',
    'mobile': '手机号',
    'username': '姓名',
    'timeOfEntry': '入职日期',
    'formOfEmployment': '聘用形式',
    'correctionTime': '转正日期',
    'workNumber': '工号',
    'departmentName': '部门',
    'staffPhoto': '头像地址'
    }
    
    // header => ['id', '手机号', '用户名', ...]
    // data => [[value值....], [], ...]

    const enKeys = Object.keys(rows[0]) // 取出对象的属性名(英文的)
    const header = enKeys.map(enKey => {
        return map[enKey]
    }) // 中文属性名(表头)

    // 表格内容, data中是嵌套数组 [[], []]
    const data = rows.map(obj => { // rows格式 [{}, {}]
        return Object.values(obj)
    })

    return { header, data }
}



const rows = [{"id":"604f764971f93f3ac8f365c2","mobile":"13800000002","username":"管理员","password":"e10adc3949ba59abbe56e057f20f883e","timeOfEntry":"2018-11-02","formOfEmployment":1,"workNumber":"9002","correctionTime":"2018-11-30","departmentName":"总裁办","staffPhoto":"http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907"},{"id":"604f764971f93f3ac8f365c3","mobile":"13800000003","username":"孙财","password":"e10adc3949ba59abbe56e057f20f883e","timeOfEntry":"2018-11-04","formOfEmployment":1,"workNumber":"111","correctionTime":"2018-11-20","departmentName":"市场部","staffPhoto":"http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907"},{"id":"604f764971f93f3ac8f365c4","mobile":"13800000004","username":"罗晓晓","password":"e10adc3949ba59abbe56e057f20f883e","timeOfEntry":"2018-12-02","formOfEmployment":1,"workNumber":"1111","correctionTime":"2018-12-31","departmentName":"人事部","staffPhoto":"http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907"},{"id":"604f764971f93f3ac8f365c5","mobile":"13400000001","username":"文吉星","password":"e10adc3949ba59abbe56e057f20f883e","timeOfEntry":"2018-01-01","formOfEmployment":1,"workNumber":"1001","correctionTime":"1970-01-01","departmentName":"人事部"},{"id":"604f764971f93f3ac8f365c6","mobile":"13400000002","username":"巴思慧","password":"e10adc3949ba59abbe56e057f20f883e","timeOfEntry":"2018-01-01","formOfEmployment":1,"workNumber":"1002","correctionTime":"1970-01-01","departmentName":"人事部"}]